<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets" 
          
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <f:metadata>
            <f:viewParam name="page" value="#{drugBean.page}"/>
            <f:viewParam name="drugName" value="#{drugBean.drugSearchName}"/>
        </f:metadata>         
    </h:head>
    <h:body>
        <ui:composition template="template/masterlayout.xhtml">
            <ui:define name="pagetitle">
                All Drugs
            </ui:define>
            <ui:define name="breadcrumb">
                <h:link value="Dashboard" outcome="index"/> &raquo; <h:link value="All drugs" outcome="drugs"/>
            </ui:define>
            <ui:define name="content">
                <div class="alert-box #{drugBean.messageStyle}"><span>#{drugBean.messageStyle} </span>#{drugBean.message}</div>
                <h:form styleClass="searchform">
                    <h:outputLabel for="drugName">Drug Name: </h:outputLabel>
                    <h:inputText id="drugName" value="#{drugBean.drugSearchName}"/>
                    <h:commandButton styleClass="button-submit" value="Search Drug" action="drugs"/>
                </h:form>
                <div class="clear"></div>
                <h:form>
                <h:dataTable value="#{drugBean.drugs}" var="drug" columnClasses="drugName,drugPrice,action">
                    <h:column>
                        <f:facet name="header">Drug Name</f:facet>
                        #{drug.drugName}
                    </h:column>
                    <h:column>
                        <f:facet name="header">Price</f:facet>
                        #{drug.drugPrice} $
                    </h:column>
                    <h:column>
                        <f:facet name="header">Action</f:facet>
                        <h:link styleClass="view" value="View" outcome="drug">
                            <f:param name="drugID" value="#{drug.drugID}"/>
                        </h:link>
                        <h:link styleClass="edit" value="Edit" outcome="editdrug">
                            <f:param name="drugID" value="#{drug.drugID}"/>
                        </h:link>
                        <h:commandLink styleClass="delete" value="Delete" action="#{drugBean.deleteDrug(drug.drugID)}"></h:commandLink>                             
                    </h:column>
                </h:dataTable>
                </h:form>
                <ul id="pagination-digg">
                    <ui:repeat value="#{drugBean.pagings}" var="page">
                        <li>
                            <h:link outcome="drugs" value="#{page}">
                                <f:param name="page" value="#{page}"/>
                                <f:param name="drugName" value="#{drugBean.drugSearchName}"/>
                            </h:link>
                        </li>    
                    </ui:repeat>
                </ul>
            </ui:define>
        </ui:composition>
    </h:body>
</html>

